import java.util.Scanner;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/12/22 20:30
 * 数组元素循环右移问题
 * 算法：数组
 */
public class _1008 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) nums[i] = sc.nextInt();
        // 排除 m 大于 n 的情况
        m = m % n;
        int split = n - m;
        StringBuilder sb = new StringBuilder();
        for (int i = split; i < n; i++) sb.append(nums[i]).append(" ");
        for (int i = 0; i < split; i++) sb.append(nums[i]).append(" ");
        System.out.println(sb.substring(0, sb.length() - 1));
    }

}
